package com.ww.springboot.boot.javabase.serial;

import org.apache.commons.io.IOUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * 描述：序列化实例
 *
 * @author 🧑 ‍wanwei
 * @since 2022-12-09 15:55
 */
public class SerialDemo1 {

    public static void main(String[] args) {
//Initializes The Object
        User1 user = new User1();
        user.setName("hollis");
//Write Obj to File
        ObjectOutputStream oos = null;
        try {
            oos = new ObjectOutputStream(new FileOutputStream("tempFile"));
            oos.writeObject(user);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(oos);
        }
    }
}

